home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / drivers2.zip / PKTCHK.ASM < prev    next >
Assembly Source File  |  1992-01-23  |  4KB  |  154 lines

  1. version    equ    1
  2.  
  3. ;  Copyright, 1988-1992, Russell Nelson, Crynwr Software
  4. ;  Modified TERMIN.ASM to be PKTCHK.ASM return errorlevel, don't terminate
  5. ;    07/24/89 Glen Marianko, Albert Einstein College of Medicine
  6.  
  7. ;   This program is free software; you can redistribute it and/or modify
  8. ;   it under the terms of the GNU General Public License as published by
  9. ;   the Free Software Foundation, version 1.
  10. ;
  11. ;   This program is distributed in the hope that it will be useful,
  12. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;   GNU General Public License for more details.
  15. ;
  16. ;   You should have received a copy of the GNU General Public License
  17. ;   along with this program; if not, write to the Free Software
  18. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20.     include    defs.asm
  21.  
  22. code    segment word public
  23.     assume    cs:code, ds:code
  24.  
  25.     org    80h
  26. phd_dioa    label    byte
  27.  
  28.     org    100h
  29. start:
  30.     jmp    start_1
  31.  
  32. copyleft_msg    label    byte
  33.  db "Packet checker version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version," copyright 1990, Russell Nelson.",CR,LF
  34.  db "This program is free software; see the file COPYING for details.",CR,LF
  35.  db "NO WARRANTY; see the file COPYING for details.",CR,LF
  36.  
  37. int_pkt    macro
  38.     pushf
  39.     cli
  40.     call    their_isr
  41.     endm
  42.  
  43. their_isr    dd    ?
  44. packet_int_no    db    0,?,?,?
  45. packet_int_end  db    0,?,?,?
  46. signature    db    'PKT DRVR',0
  47. signature_len    equ    $-signature
  48. got_int        db    0
  49. no_signature_msg    db    "Packet driver not found.",CR,LF,'$'
  50. signature_msg    db    "Packet driver found at ",'$'
  51. no_signatures_msg    db    "No packet driver found in specified range.",CR,LF,'$'
  52. usage_msg    db    "usage: pktchk <packet_int_no> (packet_int_no_end)",CR,LF,'$'
  53.  
  54. usage_error:
  55.     mov    dx,offset usage_msg
  56. error:
  57.     mov    ah,9
  58.     int    21h
  59. err_quit:
  60.     mov    al,1
  61.         mov     ah,04ch                 ; exit with errorlevel 1
  62.         int     21h
  63.  
  64. start_1:
  65.     mov    si,offset phd_dioa+1
  66.     call    skip_blanks
  67.     cmp    al,CR            ;end of line?
  68.     je    usage_error
  69.  
  70.     mov    di,offset packet_int_no
  71.     call    get_number
  72.     cmp    packet_int_no+1,0
  73.     jne    usage_error
  74.  
  75.     mov    di,offset packet_int_end
  76.     call    get_number
  77.     cmp    packet_int_end+1,0
  78.     jne    usage_error
  79.     mov    di,si
  80.     call    skip_blanks
  81.     cmp    al,CR            ;end of line?
  82.     jne    usage_error
  83.  
  84.     cmp    packet_int_end,0
  85.     jne    chk_range        ; second arg specified
  86.  
  87.     call    chk_int
  88.     jne    no_signature_err
  89.     call    pkt_found
  90. all_done:
  91.     mov    al,0
  92.     mov    ah,04ch
  93.     int    21h            ; exit with errorlevel 0
  94.  
  95. no_signature_err:
  96.     mov    dx,offset no_signature_msg
  97.     jmp    error
  98.  
  99. chk_range:
  100.     mov    al,packet_int_end
  101.     sub    al,packet_int_no
  102.     jc    usage_error
  103.  
  104. chk_loop:
  105.     call    chk_int
  106.     jne    chk_none
  107.     call    pkt_found
  108.     inc    got_int            ; flag we got one
  109. chk_none:
  110.     mov    al,packet_int_no
  111.     cmp    packet_int_end,al
  112.     jz    no_signatures_chk
  113.     inc    packet_int_no        ; increment
  114.     jmp    chk_loop
  115.  
  116. no_signatures_chk:
  117.     cmp    got_int,0
  118.     jnz    all_done
  119.  
  120. no_signatures:
  121.     mov    dx,offset no_signatures_msg
  122.     jmp    error
  123.  
  124.     public    chk_int
  125. chk_int:
  126.     mov    ah,35h            ;get their packet interrupt.
  127.     mov    al,packet_int_no
  128.     int    21h
  129.     mov    their_isr.offs,bx
  130.     mov    their_isr.segm,es
  131.     lea    di,3[bx]
  132.     mov    si,offset signature
  133.     mov    cx,signature_len
  134.     repe    cmpsb
  135.     ret
  136.  
  137.     public    pkt_found
  138. pkt_found:
  139.     mov    dx,offset signature_msg
  140.     mov    di,offset packet_int_no
  141.     jmp    print_number
  142.  
  143.     include    getnum.asm
  144.     include    skipblk.asm
  145.     include    getdig.asm
  146.     include    decout.asm
  147.     include    digout.asm
  148.     include    chrout.asm
  149.     include    printnum.asm
  150.  
  151. code    ends
  152.  
  153.     end    start
  154.